package com.littcore.saap.assistant.vo;

import java.io.Serializable;

import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.ArrayUtils;

import com.littcore.saap.assistant.po.Attachment;
import com.littcore.saap.common.vo.IUserInfo;
import com.littcore.saap.core.common.SaapConstants;
import com.littcore.util.StringUtils;

/**
 * AttachmentVo.
 * 
 * <pre><b>描述：</b>
 *    
 * </pre>
 * 
 * <pre><b>修改记录：</b>
 *    
 * </pre>
 * 
 * @author <a href="mailto:littcai@hotmail.com">蔡源</a>
 * @since 2014年4月28日
 * @version 1.0
 */
public class AttachmentVo extends Attachment implements Serializable {
	/**
	 * UID
	 */
	private static final long serialVersionUID = 1L;	
	
	private IUserInfo createUser;

	public AttachmentVo() {
	}
	
	/**
	 * 获得文件类型.
	 * 根据不同类型在界面上不同呈现
	 * image：图片呈现
	 * video：H5视频
	 * audio：音频
	 * other：未知类型
	 */
	public String getFileType()
	{	  
	  String ext = FilenameUtils.getExtension(getFileName());
	  if(StringUtils.isEmpty(ext))
	    return "other";
	  ext = ext.toLowerCase();
	  if(ArrayUtils.contains(SaapConstants.IMAGE_EXTS, ext))
	    return "image";
	  else if(ArrayUtils.contains(SaapConstants.VIDEO_EXTS, ext))
      return "video";
	  else if(ArrayUtils.contains(SaapConstants.AUDIO_EXTS, ext))
      return "audio";
	  else {
      return "other";
    }
	}
	
  /**
   * @return the createUser
   */
  public IUserInfo getCreateUser()
  {
    return createUser;
  }

  
  /**
   * @param createUser the createUser to set
   */
  public void setCreateUser(IUserInfo createUser)
  {
    this.createUser = createUser;
  }
	
	
	
}
